using System;
using System.Collections.Generic;
using System.Drawing;
using NobleTech.Products.CreatureKingdom.Utils;

namespace NobleTech.Products.CreatureKingdom
{
    public class OrganismInfo
    {
        public Guid ID;
        public Type Type;
        public Color Colour;
        public PointD ApproximateLocation;
        /// <summary>
        /// Radius of the creature (max distance from location to any part of it)
        /// </summary>
        public double Size;
        /// <summary>
        /// Whether the Organism is alive (copied from Abilities)
        /// </summary>
        public bool Alive;
        /// <summary>
        /// The notes that an Organism can sing
        /// </summary>
        public enum Note { None, C, D, E, F, G, A, B }
        public Note HighNote,
            LowNote;
        /// <summary>
        /// Which way the Organism is facing, either set explicitly in or derived from a Move
        /// </summary>
        public double ApproximateDirectionFacing;
        public List<Move.Interaction> Interactions;

        public OrganismInfo(Guid id, Type type, double size)
        {
            this.ID = id;
            this.Type = type;
            this.Colour = Color.FromArgb((int)((uint)id.GetHashCode() & 0x00FFFFFF | 0xFF000000));
            this.Size = size;
            this.Alive = true;
            this.Interactions = new List<Move.Interaction>();
        }

        public OrganismInfo(OrganismInfo other)
        {
            this.ID = other.ID;
            this.Type = other.Type;
            this.Colour = other.Colour;
            this.ApproximateLocation = other.ApproximateLocation;
            this.Size = other.Size;
            this.Alive = other.Alive;
            this.HighNote = other.HighNote;
            this.LowNote = other.LowNote;
            this.ApproximateDirectionFacing = other.ApproximateDirectionFacing;
            this.Interactions = new List<Move.Interaction>(other.Interactions);
        }

        public void AddInteraction(Move.Interaction.Types type, Guid target)
        {
            Interactions.Add(new Move.Interaction(type, target));
        }

        public override string ToString()
        {
            return string.Format("{{OrganismInfo: ID={0}; Type={1}; Location={2}}}", ID, Type.Name, ApproximateLocation);
        }
    }
}
